←Back to home

OnlineMeeting doc

August 16, 2025

πŸ§‘β€πŸ’» Online Meeting Room

A modern, real-time video meeting application built with React, Next.js, WebRTC, and SignalR. This project enables users to join virtual rooms, share audio/video, and interact with other participants in real timeβ€”all in the browser.


πŸš€ Features

  • πŸ”‘ Join/Leave Meeting:
    Enter your name, select audio/video devices, and join a meeting room. Leave gracefully with a single click.
  • πŸŽ₯ Real-Time Video/Audio:
    Peer-to-peer video and audio streaming using WebRTC. See yourself and all other participants live.
  • πŸ‘₯ Participant List:
    Sidebar displays all current participants, with your own identity clearly marked.
  • πŸ–ΌοΈ Dynamic Main Video:
    Click any participant to view their video in the main area.
  • πŸ› οΈ Device Selection Modal:
    Choose which devices (camera/microphone) to enable before joining.
  • πŸ”„ Real-Time Updates:
    Participant list and video streams update instantly as users join or leave.
  • 🧹 Clean Disconnection:
    Server is reliably notified when a user leaves, ensuring accurate participant state.

πŸ—οΈ Architecture & Technologies

LayerTechnologyPurpose
FrontendReact, Next.js (App Dir)UI, routing, state management
UI Componentsshadcn/ui, Tailwind CSSModern, accessible UI
SignalingSignalR (@microsoft/signalr)Real-time messaging, participant sync
MediaWebRTCPeer-to-peer video/audio streaming
LanguageTypeScriptType safety, better DX

πŸ“ Key Files

  • /app/onlineMeeting/[id]/page.tsx
    Main meeting room UI. Handles device selection, participant list, video rendering, and leave logic.

  • /app/onlineMeeting/[id]/useSignalR.tsx
    Custom React hook for SignalR connection, signaling, peer connection management, and participant state.


🧩 Core Logic & Flow

1. User Joins Meeting

  • User enters name and selects devices in a modal.
  • getUserMedia is called to obtain local media stream.
  • After local stream is ready, SignalR connection is established and user joins the room.

2. Signaling & Peer Connection

  • SignalR handles:
    • ParticipantsUpdated: Keeps all clients' participant lists in sync.
    • NewParticipant: Notifies existing users to establish new peer connections.
    • ReceiveSignal: Handles WebRTC offer/answer/candidate exchange.
  • Each peer connection is created only after the local stream is available, ensuring tracks are added correctly.

3. Media Stream Management

  • Local and remote streams are managed via React refs.
  • Main video area displays the selected participant's stream.
  • Each participant's video is rendered in the sidebar, with the current user highlighted.

4. Leaving the Meeting

  • On "Leave Meeting" button click:
    • SignalR LeaveRoom is invoked and connection is stopped.
    • User is redirected to the meeting home page.
  • As a fallback, beforeunload event attempts to notify the server synchronously.

⚑ Technical Highlights & Challenges

πŸ”„ WebRTC & SignalR Integration

  • Challenge: Ensuring local media is ready before peer connections are created.
  • Solution: Only start SignalR and peer connections after getUserMedia resolves.

πŸ•°οΈ React Ref Timing

  • Challenge: Video refs may be null if the DOM is not ready.
  • Solution: Use useEffect to assign streams only after refs and streams are available.

🧹 Reliable Disconnection

  • Challenge: Browsers may not wait for async operations in beforeunload.
  • Solution: Main leave logic is handled on user action; beforeunload is a best-effort fallback using .send.

πŸ§‘β€πŸ€β€πŸ§‘ Participant State Consistency

  • Challenge: Keeping all clients' participant lists and streams in sync.
  • Solution: SignalR events update state reactively; peer connections are managed per participant.